package com.tusuo.stds.ui.mobilenum;

import android.support.annotation.NonNull;
import android.widget.TextView;

import com.tusuo.stds.R;
import com.tusuo.stds.ui.BaseToolbarActivity;
import com.tusuo.stds.ui.ToolbarOwner;
import com.tusuo.stds.util.Utils;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;
import org.androidannotations.annotations.res.ColorRes;
import org.androidannotations.annotations.res.StringRes;

import java.util.ArrayList;
import java.util.List;

import myandroid.library.util.ApplicationHelper;

@EActivity(R.layout.activity_bind)
public class BindActivity extends BaseToolbarActivity<BindView, BindPresenter>
                                implements BindView {

    @ViewById(R.id.bind_tv_mobile_num)
    TextView tvMobileNum;

    @StringRes(R.string.toolbar_title_bind)
    String toolbarTitle;

    @ColorRes(R.color.colorPrimary)
    int toolbarBgColor;
    @ColorRes(R.color.textColorPrimary)
    int toolbarTextColor;

    @AfterViews
    void afterViews() {
        setupUI(this, toolbarBgColor, toolbarTextColor);

        List<ToolbarOwner.MenuAction> menuActionList = new ArrayList<>();

        ToolbarOwner.Config config = new ToolbarOwner.Config(toolbarTitle, true, R.drawable.ic_back_dark, menuActionList);
        mToolbarOwner.setConfig(config);

        String mobileNum = getIntent().getStringExtra("mobileNum");
        tvMobileNum.setText(getString(R.string.bind_mobile_num, mobileNum));

        ApplicationHelper.getInstance().addActivity(this);
    }

    @NonNull
    @Override
    public BindPresenter createPresenter() {
        return new BindPresenter(this);
    }

    @Click(R.id.bind_btn_change)
    void clickChangeBtn() {
        if (Utils.UI.isFastDoubleClick()) {
            return;
        }

        presenter.changeMobileNum();
    }
}
